import i18n from '@/i18n'
import { MetaHistoryChartDao } from '@apps/meta/domain/meta-history-chart/meta-history-chart.dao'
import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common'
import { ApiOperation, ApiTags } from '@nestjs/swagger'
import { MetaHistoryChartGetByPlatformDto } from './dto/meta-history-chart-get-by-platform.dto'
import { MetaHistoryChartSaveDto } from './dto/meta-history-chart-save.dto'
import { MetaHistoryChartUpdateByIdDto } from './dto/meta-history-chart-update-by-id.dto'

@ApiTags(i18n.t('meta-history-chart.meta-history-chart.002580-0'))
@Controller({
  path: 'history_chart',
  version: '1',
})
export class MetaHistoryChartController {
  constructor(private readonly historyChartDao: MetaHistoryChartDao) {}

  @ApiOperation({ summary: i18n.t('meta-history-chart.meta-history-chart.002580-1') })
  @Get()
  async getByPlatform(@Query() param: MetaHistoryChartGetByPlatformDto) {
    return this.historyChartDao.getByPlatform(param)
  }

  @ApiOperation({ summary: i18n.t('meta-history-chart.meta-history-chart.002580-2') })
  @Post()
  async updateById(@Body() param: MetaHistoryChartUpdateByIdDto) {
    await this.historyChartDao.updateById(param.id, param)
  }

  @ApiOperation({ summary: i18n.t('meta-history-chart.meta-history-chart.002580-3') })
  @Put()
  async save(@Body() param: MetaHistoryChartSaveDto) {
    return await this.historyChartDao.save(param)
  }
}
